package org.example.game.biweekly.game152;

import java.util.HashMap;
import java.util.Map;

public class Solution002 {


    private Map<String, Integer> sheet;

//    public Spreadsheet(int rows) {
//        sheet = new HashMap<>();
//    }

    public void setCell(String cell, int value) {
        sheet.put(cell, value);
    }

    public void resetCell(String cell) {
        sheet.put(cell, 0);
    }

    public int getValue(String formula) {

        int res = 0;
        String first = formula.split("\\+")[0].substring(1);
        if(first.equals(first.toLowerCase())){
            res += Integer.parseInt(first);
        }else {
            res += sheet.getOrDefault(first, 0);
        }
        String second = formula.split("\\+")[1];
        if(second.equals(second.toLowerCase())){
            res += Integer.parseInt(second);
        }else {
            res += sheet.getOrDefault(second, 0);
        }
        return res;
    }

}
